package com.example.collection;

import java.util.ArrayList;
import java.util.LinkedList;

/**
 * @author 胡帅博
 * @date 2021/1/28 22:58
 */
public class ObjectPool2<T>{


    Node<T> head;

    Node<T> tail;


    private static class Node<E>{
        E item;
        ObjectPool2.Node<E> next;

        Node(E var2, ObjectPool2.Node<E> var3) {
            this.item = var2;
            this.next = var3;
        }
    }


    public void add(T t) {
        tail.next = new Node<>(t, null);
    }

    public T getAndRemove() {
        T t = head.item;
        head = head.next;
        return t;
    }


}
